<template>
    <el-row>
        <el-col class="btn">
          <el-dialog :visible.sync="dialogauditVisible" width="635px" :before-close="handleClose" @close="handleClose()">
              <div slot="title" class="dialog-title box box-align-center">
                  <i class="title-icon"></i>
                  <span class="title-text ml10">自动审核开关</span>
              </div>
              <el-form :model="did" status-icon :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
                <el-form-item label="时间间隔(秒)" prop="autoapprovelong">
                  <el-input type="number" :min="1" :max="600" v-model="did.autoapprovelong"  autocomplete="off" placeholder="请输入审核时间间隔"></el-input>
                </el-form-item>
             </el-form>
              <span slot="footer" class="dialog-footer">
                  <el-button class="reset-cancel-btn" @click="handleClose()">取 消</el-button>
                  <el-button class="reset-comfirm-btn" @click="onSubmit()">确定</el-button>
              </span>
          </el-dialog>
        </el-col>
    </el-row>
</template>

<script>
    export default {
        props:{
            dialogauditVisible:{
                type:Boolean,
            },
            did:{
            },
        },
        data() {
          return {
               rules: {
                autoapprovelong: [
                  { required: true, message: '请输入时间间隔', trigger: 'blur' },
                 {
                 pattern: /^([1-9]|[123][0-9]|600)$/,
                 message: '格式错误,最小为1秒,最大为600秒',
                 trigger: 'blur'
                 }
               ]
            }
          }
        },

        methods: {

          chk(){
              if(this.did.autoapprovelong>31){
                  this.did.autoapprovelong=1;
              }
          },
          handleClose() {
              this.$emit('clickCloses')
          },
          onSubmit() {
              this.$refs.ruleForm.validate((valid) => {
                  if(valid){
                      let params={
                            id:this.did.id,
                            autoapprovelong:this.did.autoapprovelong
                      }
                      this.$ajax.post('/yschool/openAuto',params).then(res=>{
                           this.$message({ message: '['+this.did.name+']自动审核功能已开启', type: 'success' });
                           this.handleClose();
                           this.$emit('init');

                      })
                  }
                  })


          },
        }
      }
</script>

<style scoped lang="scss">
   /deep/ .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
        background: #F6F7FA;
      }
      .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
      }
      .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
      }
      .avatar {
        width: 178px;
        height: 178px;
        display: block;
      }
</style>
